package com.example.car;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class RankingsActivity extends Activity {

	private static final String KEY_RANK = "rank"; // NOTE: this field does not
													// avaliable in json, just
													// ranking of user
	private static final String KEY_NAME = "name";
	private static final String KEY_AUTOMAKE = "autoMake";
	private static final String KEY_AUTOMODEL = "autoModel";
	private static final String KEY_ENGINE = "engine";
	private static final String KEY_OBJECTTYPE = "objectType";
	private static final String KEY_PHOTO = "photo";
	private static final String KEY_SET = "set";
	private static final String KEY_STATS = "stats";
	private static final String KEY_TAGS = "tags";
	private static final String KEY_YEAR = "year";
	private static final String KEY_TOPSPEED = "topSpeed";
	private static final String KEY_ACCELERATION100 = "acceleration100";
	private static final String KEY_ACCELERATION160 = "acceleration160";
	private static final String KEY_POWER = "power";
	private static final String KEY_TORQUEFORCE = "torqueForce";
	private static final String KEY_TORQUERPM = "torqueRPM";
	private static final String KEY_CREDITNAME = "creditName";
	private static final String KEY_CREDITURL = "creditURL";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_rankings);
		STATIC static_var = (STATIC) getApplicationContext();

		ListView listView = (ListView) findViewById(R.id.list);

		ListAdapter adapter = new SimpleAdapter(RankingsActivity.this,
				static_var.carList, R.layout.activity_ranking_item,
				new String[] { KEY_RANK, KEY_AUTOMAKE, KEY_NAME }, new int[] {
						R.id.rankingItem_NO, R.id.rankingItem_Model,
						R.id.rankingItem_Name });
		// Assign adapter to ListView
		listView.setAdapter(adapter);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_rankings, menu);
		return true;
	}

}
